#include<bits/stdc++.h>
#define int long long
using namespace std;
void fileopen(string s)
{
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
int d[100007],v[100007],a[100007],p[100007],n,m,L,V,ans;
bool over[100007];
int special_calc()
{
    if(ans==0)
    {
        return m;
    }
    return m-1;
}
bool open[100007];
bool check()
{
    int i,j;
    vector<int> vp;
    for(i=1;i<=m;i++)
    {
        //cerr<<open[i];
        if(open[i])
        {
            vp.push_back(p[i]);
        }
    }
    //cerr<<'\n';
    int res=0,lt=vp.size();
    for(i=1;i<=n;i++)
    {
        for(j=lower_bound(vp.begin(),vp.end(),d[i])-vp.begin();j<lt;j++)
        {
            if(sqrt(v[i]*v[i]+2*a[i]*(vp[j]-d[i]))>V)
            {
                res++;
                //cerr<<i<<' '<<j<<'\n';
                break;
            }
            else
            {
                if(a[i]<0)
                {
                    break;
                }
            }
        }
    }
    //cerr<<"res="<<res<<'\n';
    return res==ans;
}
int dfs(int now,int sum)
{
    if(now==m+1)
    {
        //cerr<<"now="<<now<<" sum="<<sum<<'\n';
        if(check())
        {
            return sum;
        }
        return 0;
    }
    open[now]=true;
    int t=dfs(now+1,sum);
    open[now]=false;
    t=max(t,dfs(now+1,sum+1));
    return t;
}
void solve()
{
    memset(over,false,sizeof(over));
    int i,j;
    bool special=true;
    cin>>n>>m>>L>>V;
    for(i=1;i<=n;i++)
    {
        cin>>d[i]>>v[i]>>a[i];
        if(a[i]!=0)
        {
            special=false;
        }
    }
    for(i=1;i<=m;i++)
    {
        cin>>p[i];
    }
    sort(p+1,p+m+1);
    if(!special)
    {
        ans=0;
        for(i=1;i<=n;i++)
        {
            for(j=lower_bound(p+1,p+m+1,d[i])-p;j<=m;j++)
            {
                if(sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]))>V)
                {
                    over[i]=true;
                    ans++;
                    //cerr<<i<<' '<<j<<'\n';
                    break;
                }
                else
                {
                    if(a[i]<0)
                    {
                        break;
                    }
                }
            }
        }
        cout<<ans<<' ';
    }
    else
    {
        ans=0;
        for(i=1;i<=n;i++)
        {
            if(v[i]>V&&d[i]<=p[m])
            {
                over[i]=true;
                ans++;
            }
        }
        cout<<ans<<' ';
    }
    if(special)
    {
        //cerr<<"special!!!\n";
        cout<<special_calc();
    }
    else
    {
        cout<<dfs(1,0);
    }
    cout<<'\n';
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fileopen("detect");
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
